package com.rhm.dataStructure.Leetcode;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 22:09
 * @Description:
 **/

import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2020/2/20 22:09
 *@Description:
 **/
public class Code14 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
           String s = sc.nextLine();
            String[] str = s.split(",");
            System.out.println(longestCommonPrefix(str));
        }

    }

    public static String longestCommonPrefix(String[] strs) {
        if (strs == null || strs.length == 0) return "";
        for (int i = 0; i < strs[0].length() ; i++){
            char c = strs[0].charAt(i);
            for (int j = 1; j < strs.length; j ++) {
                if (i == strs[j].length() || strs[j].charAt(i) != c){
                    return strs[0].substring(0, i);
                }
            }
        }
        return strs[0];
    }
}
